home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
basic
/
vol_inf.exe
/
FVOLAB.ASM
< prev
next >
Wrap
Assembly Source File
|
1993-05-02
|
28KB
|
757 lines
; created 02/13/92
; updated 12/21/92
; revised 04/21/93 GETVOL$
; to display Norton Utilities Safe Format volume labels.
; NU routine ends a volume label with nulls rather than spaces.
; revised 04/22/93 SETVOL
; Test if drive is a network drive and quit if it is.
; revised 04/27/93 added DOS Ver 3.xx+ version information so could
; tell source of error. FCB functions return AX = 0FFh if drive
; is invalid and do not set any critical error. Only way to tell
; if access error or if drive is invalid is to use DOS Ver 3.xx+
; Function 59h.
; revised 04/30/93 SETVOL
; to handle Norton Utilities Safe Format.
; NU routine ends a volume label with nulls rather than spaces.
; Only function that will delete such a name is FCB function
; 13h. However, that function is not safe to use
; in DOS Version 2.xx. DOS Version 2.xx marked deleted volume
; label with 00h rather than correct 0E5h which prevented access
; to rest of directory list. Function 13h in MS DOS Version 5.00,
; 3.30, and COMPAQ DOS version 3.00 does not have this problem.
; Also add check of input string for invalid characters
;=======================================================================
; Modifications Copyright (C) Copr. 1992, 1993 by Sidney J. Kelly
; All Rights Reserved.
; Sidney J. Kelly
; 150 Woodhaven Drive
; Pittsburgh, PA 15228
; home phone 412-561-0950 (7pm to 9:30pm EST)
;=======================================================================
; «RM82»«TS8,16,24,32,40,48»
DOSSEG
.MODEL MEDIUM
EXTRN B$ASSN:FAR ;This allows QBASIC to manipulate fixed length string
EXTRN B$STDL:FAR ;This creates null strings
.DATA
EXTRN B$STRINGLEN:WORD ;inside FDATA
EXTRN B$STRINGOFF:WORD ;inside FDATA
EXTRN B$TEMPDATA:WORD ;inside FDATA
; this works inside QB as well as in run time version
EXTRN __osversion :word;this holds minor version in highbyte,
;major version in lowbyte
.CODE
Public GETVOL, SETVOL
; Please do not remove
Copyright DB 13,10,'Copyright Copr. (C) 1992, 1993 Sidney J. Kelly',13,10
Copyright1 DB 'All Rights Reserved',13,10,26
EVEN ;save space in DGROUP
Old_CE Label DWORD
CE_Off DW 0 ; to save space in DGROUP
CE_Seg DW 0 ; address of previous handler
Old_DTA Label DWORD
DTA_Off DW 0 ; to save space in DGROUP
DTA_Seg DW 0 ; address of previous handler
Last_Error DW 0 ; store critical error code
; Format of an extended FCB---------------
XFCB DB 0FFh ; signal XFCB
DB 5 Dup(0) ; reserved DOS stuff
DB 8 ; volume attribute
Drive DB 0 ; drive code goes here
FLabel DB 11 Dup(0) ; Volume name
FExtra DB 5 Dup(0) ; reserved DOS stuff
FNew DB 11 Dup(0) ; holding area for renaming
FScrap DB 15 Dup(0) ; extra stuff and padding (6) extra
; Duncan, "Advanced MS DOS Programming" (Microsoft 1988), p366
; "Microsoft MS-DOS Programmer's Reference Guide" (Microsoft 1991)
;=======================================================================
; DECLARE FUNCTION GETVOL$(Drive$, DosErr%)
; T$ = GETVOL$(Drive$, DosErr%)
; Purpose:
; Returns current volume label of Drive$
; Input:
; Drive$ = Drive letter between 'A' to 'Z'. If out-of-range then
; default drive is substituted
; Output:
; T$ = the volume label. Note that volume labels can contain spaces.
; If any error encountered, returns NULL string
; DosErr:
; 0 if no critical error
; -1 if FCB error in DOS version 2.xx
; -2 if DOS Version 4.xx w/o SHARE
; Else
; Standard DOS errors from function 59h
; 18 = Drive has no label
; 21 = Drive not ready
; Theory:
; FCB's are used because they work under DOS version 2.x and they
; report the name without putting a period between the first
; 8 letters and the last 3 or squeezing out all the spaces.
;
; Note:
; Under DOS Ver 4.00, if SHARE is not loaded, then will return with
; a null string to prevent corruption of a large partition by reason of
; the use of FCBs.
;
; If drive is not valid, returns a null string and an error code.
;
; Has own critical error handler.
;=======================================================================
DrvStrg EQU [BP+8] ; mnemonic for programmer
DosErr EQU [BP+6]
EVEN
GETVOL PROC FAR
Push BP
Mov BP,SP ; get access to stack via BP
Push SI ; save index registers
Push DI ; ditto
; Mov AH,30h ; do a DOS version check
; Int 21h
Mov AX,__osversion ; faster than above
Cmp AL,4 ; DOS version 4.xx
Jne @f ; not version 4.xx so skip ahead
Mov AX,1000h ; else, (AL must = 0)
Int 2Fh ; see if SHARE installed
Cmp AL,0FFh ; if AL = FFh then it is installed
Je @f ; o.k. to continue
Mov CS:[Last_Error],-2 ; report DOS Ver 4.0x w/o SHARE
Jmp Short Error ; else, return null string, error
@@:
;Install CE Handler, trashes AX,BX,ES,DX, returns AX = @data
Call CE_INSTALL
Mov BX,DrvStrg ; get DRIVE$
Mov CX,[BX] ; get length in CX
JCXZ Use_Default ; if LEN(Drive$) = 0 use default drive
Mov BX,[BX+2] ; get offset of string
Mov AL,[BX] ; get character in AL
And AL,0DFh ; capitalize character
Sub AL,'@' ; make it 1 biased
Or AL,AL ; is it 0?
Jz Begin ; yes, so use default drive
Cmp AL,27 ; is it > 26?
JB Begin ; no, so test it
Use_Default:
Mov AH,19h ; else read default drive
Int 21h ; into AL (useful for testing)
Begin:
; AL must contain desired drive
Call Search_4_Name ; search for current volume name
; must preserve DI because will use it below
Assume DS:NOTHING, ES:NOTHING ; tell MASM
Cmp AL,0FFh ; name found?
Jne @f ; yes, so check for CE errors
Call GetErrInfo ; else find out why not found
@@:
Cmp CS:[Last_Error],0 ; did DOS give us an error?
Jne Error ; got an error
; new version
; revised 04/21/93 to handle Norton Utilities Safe Format
; NU routine ends a volume label with nulls rather than spaces. While
; QBASIC PRINT function can display nul strings, other routines
; may trigger errors.
Mov CX,11 ; else, search for trailing spaces
Dec DI ; remove 1 char overrun from DI
Mov BL,20h ; look for a space
Search_4_End:
Mov AL,ES:[DI] ; get character
Cmp AL,BL ; is it a space?
Je @f ; yes, jump ahead
Or AL,AL ; is it a nul?
Jne Loop_Exit ; no, have end of label
@@:
Dec DI ; reduce pointer by 1
Loop Search_4_End ; loop CX times
Loop_Exit:
JCXZ Error ; all spaces/nuls if CX = 0
; copy our string to DGROUP buffer
Mov DX,CX ; save length in DX temporarily
Mov SI,OFFSET FLabel ; put source string in DS:SI
Mov AX,SS
Mov ES,AX
; Assume ES:@data
Assume DS:@data ; lie for a moment
Mov DI,OFFSET B$TEMPDATA ; put destination in ES:DI
Assume DS:NOTHING ; tell the truth again
Rep MovsB ; store all the bytes
Mov CX,DX ; restore CX to original length
CopyString:
; Reset CE Handler, trashes AX,DX, returns AX = @data
; Note: must preserve CX!
Call Clean_Up ; restore CE and DTA info
Assume DS:@data
; return string to BASIC
Push DS ; Store the Data Segment
Mov AX,OFFSET B$TEMPDATA
Push AX ; Store offset of string
Push CX ; Store LEN of string
Push DS ; Store the Data Segment
Mov AX,OFFSET B$STRINGLEN
Push AX ; Store Descriptor of string
Xor AX,AX ; tell Basic it is a variable strin